package com.example.demo2.controller;

import com.example.demo2.biz.Userbiz;
import com.example.demo2.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

@RestController
@SpringBootApplication
public class get {
    private Object problem;
    private Object answer;

    @RequestMapping("getProblem")
    public Map<String, Object> getUser(){
        System.out.println("微信小程序正在调用");
        Map<String, Object> map = new HashMap<String,Object>();
        List<String> list = new ArrayList<String>();
        List<String> list1 = new ArrayList<String>();
        Set set1 = new HashSet();
       for(int i=0;i<=0;i++){
           String d="";
           int a=(int)(Math.random()*10);
           int b=(int)(Math.random()*10);
           int c=(int)(Math.random()*3);


           int e =0;
           if (c==0){
               d="+";
               e=a+b;
           }else if (c==1){
               d="-";
               e=a-b;
           }else if (c==2){
               d="*";
               e=a*b;
           }else if (c==3){
               d="/";
               e=a/b;
           }
           set1.add(e);
           while(set1.size()<=3){
               int random = (int)(Math.random()*81);
               set1.add(random);
           }
           list.add(a+d+b);
           list.add(e+"");
           for(Object s:set1){
               list1.add(s+"");
           }
           int random1;
           random1 = (int)(Math.random()*4);
           for(int j=0;j<=3;j++)
           {
               if(random1+j<=3) {
                   list.add(list1.get(random1 + j));
               }
               else{
                   list.add(list1.get(random1 + j-4));
               }
           }
           map.put("list",list);

        }


        System.out.println("微信小程序调用完成");
        return map;
    }



//    @RequestMapping("")
//    public String getText(){
//        return "hello world";
//    }


}
